package com.fxd.controller;

import com.fxd.domain.account;
import com.fxd.service.accountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * @auther fuxudong
 * @date 2021/2/7 - 12:11
 */
@Controller
@RequestMapping("account")
public class accountController {

    @Autowired
    private accountService accountService;


    @RequestMapping("findall")
    public String findall(Model model){
        List<account> list = accountService.findAll();
        model.addAttribute("list",list);
        return "list";
    }

    @RequestMapping("save")
    public void save(account account, HttpServletRequest request, HttpServletResponse response)throws Exception{
        accountService.saveAccount(account);
        System.out.println(request.getContextPath());
        response.sendRedirect(request.getContextPath()+"/account/findall");
        return;
    }




}
